home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGASIC / STRBASIC.LZH / SB.DOC < prev    next >
Text File  |  1984-10-10  |  30KB  |  1,021 lines

  1.  
  2.  
  3.  
  4.  
  5.                                    October 1984
  6.  
  7.         This  document tells how to use the Structured BASIC preprocessor
  8.         program,  SB.EXE,  and tells how to write programs for the IBM PC
  9.         in  the  Structured  BASIC  language. This manual assumes you are
  10.         familiar with MS DOS and Microsoft BASIC.
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                               THE BASIC NECESSITIES                              THE BASIC NECESSITIES
  23.                            PREPROCESSOR USER'S MANUAL                           PREPROCESSOR USER'S MANUAL
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.                              Manual version:   1.12
  31.  
  32.                              Software version: 1.12
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.                                    Marty Franz
  49.  
  50.                      525 W. Walnut St., Kalamazoo, MI 49007
  51.  
  52.                                  (616) 344-1821
  53.  
  54.  
  55.  
  56.                (C) Copyright 1983 Marty Franz - All rights reserved
  57.  
  58.  
  59.  
  60.  
  61.         100784112         Preprocessor User's Manual
  62.  
  63.  
  64.  
  65.         INTRODUCTION        INTRODUCTION
  66.  
  67.             SB.EXE is a preprocessor program for Microsoft BASIC on the
  68.         IBM PC.  It takes a program containing special Structured BASIC
  69.         statements and translates it into a program containing BASIC
  70.         statements.  Using SB.EXE helps you write more concise, better
  71.         structured BASIC programs, because the preprocessor lets you take
  72.         advantage of these features:
  73.  
  74.             - you now have the ability to write free-form, indented
  75.               statements without line numbers.
  76.  
  77.             - you can now include statements from many separate files
  78.               into a single BASIC program. This lets you write and
  79.               maintain your programs in small modules.
  80.  
  81.             - you can organize your subroutines into procedures, each
  82.               with its own alphanumeric name.
  83.  
  84.             - you can use structured programming statements similar to
  85.               those found in programming languages like Pascal and C.
  86.  
  87.             Before using SB.EXE, please take the time to read these
  88.         instructions carefully.  When using it, bear in mind that this is
  89.         version 1.12 of the program, and there may be bugs in it.  If
  90.         there is, or you have suggestions on improving Structured BASIC,
  91.         please contact me:
  92.  
  93.                  Marty Franz
  94.                  525 W. Walnut St.
  95.                  Kalamazoo, MI  49007
  96.                  (616) 344-2043
  97.  
  98.             One more thing: the program, and this manual, are copyrighted
  99.         materials.  They may be freely distributed only for private,
  100.         noncommercial use.  Please read the copyright notice on your
  101.         diskette.
  102.  
  103.  
  104.         A SAMPLE PROGRAM        A SAMPLE PROGRAM
  105.  
  106.             Before describing Structured BASIC in too much detail, let's
  107.         first look at a typical program.  This will help you understand
  108.         what SB.EXE does.  The file LC.SB on the diskette is a good
  109.         example.  It asks for the name of a text file and counts the
  110.         number of lines in it.  You can make a listing of LC.SB on your
  111.         printer with the PRINT program supplied on the diskette:
  112.  
  113.                  A>llist lc
  114.  
  115.         (See the Utilities Manual for more information on the LLIST                 _________ ______
  116.         program.)
  117.  
  118.  
  119.  
  120.  
  121.                                                                          Page 2        100784112         Preprocessor User's Manual
  122.  
  123.  
  124.  
  125.             Your listing of LC.SB should look like this:
  126.  
  127.             'Sample program to count the lines in an ASCII file.
  128.  
  129.             procedure MAIN
  130.                on error goto CHECK.FOR.EOF
  131.  
  132.                input "File Name"; FILE.NAME$
  133.                open FILE.NAME$ for input as #1
  134.                LINE.COUNT = 0 : DONE.SW = 0
  135.                repeat
  136.                    line input #1, L$
  137.                    LINE.COUNT = LINE.COUNT+1
  138.                until DONE.SW = 1
  139.                print "There are";LINE.COUNT-1;"lines in ";FILE.NAME$
  140.             endproc
  141.  
  142.             CHECK.FOR.EOF|
  143.                ERROR.CODE = err : ERROR.LINE = erl
  144.                if ERROR.CODE = 62
  145.                   DONE.SW = 1
  146.                   resume next
  147.                else
  148.                   print "BASIC error ";ERROR.CODE;"at";ERROR.LINE
  149.                   stop 'Immediately halt program
  150.                endif
  151.             end
  152.  
  153.             This file (called a source file in this manual) was created                                ______ ____
  154.         using the ED.EXE program.  For more information about ED, see the
  155.         separate file about it on the diskette.  Don't worry at this
  156.         point about the details of each statement in the program; we'll
  157.         be covering them shortly.  For now, notice only that a Structured
  158.         BASIC program, unlike a normal BASIC program, has line-number-
  159.         free, neatly indented statements, and empty lines to separate
  160.         blocks of statements. In fact, it resembles those Pascal programs
  161.         you've seen in magazines more than BASIC.  Because the program
  162.         looks more structured than BASIC, it ought to be easier to
  163.         understand and maintain.
  164.  
  165.             Unfortunately, this program cannot be executed directly by
  166.         BASIC.  We need to convert this program into one with everyday
  167.         BASIC statements in it before we can run it.  This is what SB.EXE
  168.         does.  To build a BASIC program out of LC.SB, we enter:
  169.  
  170.                  A>sb lc
  171.  
  172.         and these messages appear:
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.                                                                          Page 3        100784112         Preprocessor User's Manual
  182.  
  183.  
  184.  
  185.                  The Structured BASIC preprocessor 1.12
  186.  
  187.                  60KB to spare
  188.                  Done with pass 2, 0 error(s) found.
  189.                  22 lines processed,  147 lines/minute.
  190.  
  191.                  A>
  192.  
  193.             After the SB.EXE is done, if we then type the output file,
  194.         LC.BAS, we see:
  195.  
  196.             A>type lc.bas
  197.  
  198.              10  'LC.SB 10-14-83   5:48a  22 lines
  199.              20  GOSUB 50
  200.              30  END
  201.              40  'Sample program to count the lines in an ASCII
  202.                  file
  203.              50  'procedure MAIN
  204.              60  on error goto 150
  205.              70  input "File Name"; FILE.NAME$
  206.              80  open FILE.NAME$ for input as #1
  207.              90  LINE.COUNT = 0 : DONE.SW = 0
  208.             100  line input #1, L$
  209.             110  LINE.COUNT = LINE.COUNT+1
  210.             120  IF NOT(DONE.SW = 1) THEN 100
  211.             130  print "There are";LINE.COUNT-1;"lines in ";FILE.NAME$
  212.             140  RETURN
  213.             150  'CHECK.FOR.EOF|
  214.             160  ERROR.CODE = ERR : ERROR.LINE = ERL
  215.             170  IF NOT(ERROR.CODE = 62) THEN 210
  216.             180  DONE.SW = 1
  217.             190  resume next
  218.             200  GOTO 230
  219.             210  print "BASIC error ";ERROR.CODE;"at";ERROR.LINE
  220.             220  stop 'Immediately halt program
  221.             230  end
  222.  
  223.             A>
  224.  
  225.         This is a conventional BASIC program that can now be run using        ____
  226.         BASIC or BASICA.
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.                                                                          Page 4        100784112         Preprocessor User's Manual
  242.  
  243.  
  244.  
  245.             To summarize our example, which demonstrated the process of
  246.         creating a Structured BASIC program:
  247.  
  248.             1. We first use a text editor to write the program. The
  249.                program contains special Structured BASIC statements
  250.                (which we'll cover soon), is free of line numbers, has
  251.                lots of blank lines and indenting, and is easier to read
  252.                and maintain than regular BASIC.
  253.  
  254.             2. We then use the preprocessor program, SB.EXE, to
  255.                translate the program into one with everyday BASIC
  256.                statements in it.
  257.  
  258.             3. The translated BASIC program is now run and debugged as
  259.                usual from BASIC.
  260.  
  261.  
  262.  
  263.         PROGRAM REQUIREMENTS        PROGRAM REQUIREMENTS
  264.  
  265.             To preprocess Structured BASIC programs, you need an IBM PC,
  266.         jr, or XT with:
  267.  
  268.             - at least 64KB of memory,
  269.  
  270.             - at least one single-sided diskette drive,
  271.  
  272.             - a color or monochrome adapter, with a monitor capable of
  273.               displaying 80-character lines.
  274.  
  275.             - MS DOS version 1.1 or 2.x, and
  276.  
  277.             - BASIC.COM or BASICA.COM
  278.  
  279.         You also need the file SB.EXE available on the diskette with
  280.         BASIC or BASICA.
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.                                                                          Page 5        100784112         Preprocessor User's Manual
  302.  
  303.  
  304.  
  305.  
  306.         STRUCTURED BASIC STATEMENTS        STRUCTURED BASIC STATEMENTS
  307.  
  308.             Your source program is composed of Structured BASIC
  309.         statements. A Structured BASIC statement is similar to an
  310.         everyday BASIC statement, except the line number is missing:
  311.         SB supplies this for you when it builds the BASIC program from
  312.         your source program.  If
  313.  
  314.                  10 PRINT "Hello, world"
  315.  
  316.         is a BASIC statement, then
  317.  
  318.                  PRINT "Hello, world"
  319.  
  320.         is the matching Structured BASIC statement.  Only the line number
  321.         is missing.  You can have any number of blanks and tab characters
  322.         in your source statements.  In fact, this is encouraged since
  323.         this helps make your Structured BASIC programs easier to read.
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.                                                                          Page 6        100784112         Preprocessor User's Manual
  362.  
  363.  
  364.  
  365.  
  366.         LABELS        LABELS
  367.  
  368.             Without line numbers in front of statements, you need another
  369.         way to mark the places in a program where control is to go during
  370.         its execution.  You can do this in Structured BASIC with
  371.         alphanumeric labels instead of line numbers. In a BASIC program,
  372.         we might write two statements as:
  373.  
  374.                  960 GOTO 1030
  375.  
  376.         and
  377.  
  378.                  1030 STOP 'End the program
  379.  
  380.         In Structured BASIC, these two statements would be written
  381.         instead as:
  382.  
  383.                  GOTO THE.END
  384.  
  385.         and
  386.  
  387.                  THE.END| STOP
  388.  
  389.             Labels can be from 1 to 32 characters in length.  Only the
  390.         characters 0-9, A-Z, a-z, and "." (period) can be in a label.
  391.         This is to keep labels from conflicting from other BASIC
  392.         keywords.  The "|" (vertical bar) is used only where the label is
  393.         defined; notice that it's not there in the GOTO statement.  It's
  394.         used to set the label off from the rest of the line.
  395.  
  396.             Another example of labels in a Structured BASIC program is in
  397.         LC.SB. The statements:
  398.  
  399.                  on error goto CHECK.FOR.EOF
  400.  
  401.         and
  402.  
  403.                  CHECK.FOR.EOF|
  404.  
  405.         also demonstrate how labels are referenced (the ON GOTO
  406.         statement) and defined (the CHECK.FOR.EOF| statement) in
  407.         Structured BASIC.
  408.  
  409.         The Structured BASIC statements that can use labels are:
  410.  
  411.                  ON ERROR GOTO {label}
  412.                  ON n GOTO {label1},{label2},...
  413.                  RESTORE {label}
  414.                  RESUME {label}
  415.                  RETURN {label}
  416.  
  417.  
  418.  
  419.  
  420.  
  421.                                                                          Page 7        100784112         Preprocessor User's Manual
  422.  
  423.  
  424.  
  425.         PROCEDURES        PROCEDURES
  426.  
  427.             Structured BASIC provides procedures to help organize your
  428.         programs.  Procedures are similar to BASIC subroutines, except
  429.         they are identified by and called with an alphanumeric name.
  430.         Procedures in Structured BASIC look like this:
  431.  
  432.                  PROCEDURE {procname}                 _________
  433.                       statements making up the procedure
  434.                  ENDPROC                 _______
  435.  
  436.         To GOSUB to a procedure you can use either:
  437.  
  438.                  GOSUB {procname}                 _____
  439.  
  440.         or
  441.  
  442.                  DO {procname}                 __
  443.  
  444.         with the rules for procedure names being the same as for label
  445.         names.
  446.  
  447.         The other Structured BASIC statements that can call procedures
  448.         are:
  449.  
  450.                  ON n DO {procname1},{procname2},...
  451.                  ON COM(n) DO {procname}
  452.                  ON KEY(n) DO {procname}
  453.                  ON PEN DO {name}
  454.                  ON PLAY(n) DO {procname}
  455.                  ON STRIG(n) DO {procname}
  456.                  ON TIMER(n) DO {procname}
  457.  
  458.             Every Structured BASIC program requires at least one
  459.         procedure, called MAIN.  Control is always given to MAIN with a
  460.         GOSUB when the program is started (see lines 10-50 of LC.BAS).
  461.         So, our "Hello, world" example needs three statements to work
  462.         properly:
  463.  
  464.                  PROCEDURE MAIN
  465.                       PRINT "Hello, world"
  466.                  ENDPROC
  467.  
  468.             Like white space, you should liberally use procedures in your
  469.         Structured BASIC programs.  They help break your program into
  470.         chunks for better organization.  Even a single statement deserves
  471.         its own procedure if doing so will make the program easier to
  472.         read.
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.                                                                          Page 8        100784112         Preprocessor User's Manual
  482.  
  483.  
  484.  
  485.         IF BLOCKS        IF BLOCKS
  486.  
  487.             The only place in your Structured BASIC programs where you
  488.         can't freely use a label to stand for a line number is in an IF
  489.         statement. Instead, a special form of IF is used in Structured
  490.         BASIC, called an "IF block".  It looks like this:
  491.  
  492.                  IF {condition1}                 __
  493.                       statements executed if {condition1} is true
  494.                  ELSEIF {condition2}                 ______
  495.                       statements executed if {condition2} is true
  496.                  ELSE                 ____
  497.                       statements executed if both conditions are false
  498.                  ENDIF                 _____
  499.  
  500.         An example of an IF block is in LC.SB:
  501.  
  502.                  if ERROR.CODE = 62
  503.                       DONE.SW = 1
  504.                       resume next
  505.                  else
  506.                       print "BASIC error ";ERROR.CODE;"at";ERROR.LINE
  507.                       stop 'Immediately halt program
  508.                  endif
  509.  
  510.         Briefly, IF the variable ERROR.CODE has the value 62 then the
  511.         statements DONE.SW = 1 and RESUME NEXT will be executed.  This
  512.         will occur if we have reached the end of the file we are reading.
  513.         If ERROR.CODE is not 62, then another, more sinister BASIC error
  514.         has occurred that we don't know how to handle.  The statements
  515.         after the ELSE display the error code and line number and stop
  516.         the program.
  517.  
  518.             There can be more than one ELSEIF clause in the IF block.
  519.         This is used to check for multiplie conditions without nesting
  520.         single IF-ELSE-ENDIF blocks deeper and deeper.
  521.  
  522.             Why should you use IF blocks in a Structured BASIC program
  523.         instead of BASIC's IF {condition} THEN {line number} statement?
  524.         Because the IF block gives you the advantage of always knowing
  525.         exactly where control begins and ends: with no GOTO statements in
  526.         the IF and ELSE parts of the block, execution beginning at the IF
  527.         statement will always resume after the ENDIF statement,
  528.         regardless of what happens in between.  With BASIC's IF
  529.         statement, you can picture control splitting into two separate
  530.         paths with each THEN.  Pretty soon, as patches and revisions are
  531.         made, your program becomes a mess of "spaghetti code".
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.                                                                          Page 9        100784112         Preprocessor User's Manual
  542.  
  543.  
  544.  
  545.             If you faithfully use the IF block for your program's logic
  546.         you should seldom find the need for a GOTO statement.  GOTOs
  547.         should be saved only for unusual conditions that require special
  548.         processing, such as errors.
  549.  
  550.             If you should require a GOTO, or you want to execute just a
  551.         single statement with an IF, Structured BASIC provides a special
  552.         "short form" of the IF for your convenience.  In addition to the
  553.         block format described above, you can use one of these formats:
  554.  
  555.                  IF {condition} BREAK
  556.                  IF {condition} DO {procname}
  557.                  IF {condition} GOSUB {procname}
  558.                  IF {condition} GOTO {label}
  559.                  IF {condition} THEN {any BASIC statement}
  560.  
  561.             These statements are for the IF only and cannot be paired
  562.         with an ELSEIF, ELSE, or ENDIF.  They are intended for
  563.         single-statement use only.
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.                                                                         Page 10        100784112         Preprocessor User's Manual
  602.  
  603.  
  604.  
  605.         REPEAT AND WHILE BLOCKS        REPEAT AND WHILE BLOCKS
  606.  
  607.             Right now, many of your program loops in BASIC are written
  608.         using IFs and GOTOs.  To help make these more structured,
  609.         Structured BASIC provides a REPEAT block for executing a group of
  610.         statements over and over until a terminating condition is
  611.         reached.  It looks like this:
  612.  
  613.                  REPEAT                 ______
  614.                       statements to keep repeating
  615.                  UNTIL {condition}                 _____
  616.  
  617.         A REPEAT block is used in LC.SB:
  618.  
  619.                  repeat
  620.                      LINE INPUT #1, L$
  621.                      LINE.COUNT = LINE.COUNT+1
  622.                  until DONE.SW = 1
  623.  
  624.         Remember that REPEAT is like any loop you might make with GOTOs
  625.         in BASIC: you need to change something at some point in the
  626.         statements you're repeating to stop the loop or you'll continue
  627.         forever.
  628.  
  629.             Besides meeting the condition for termination, you can use a
  630.         BREAK statement in the REPEAT block to transfer control
  631.         immediately outside the loop.  To use a BREAK statement, simply
  632.         specify
  633.  
  634.                  BREAK                 _____
  635.  
  636.             Besides REPEAT, Structured BASIC provides a WHILE loop
  637.         similar to the one already in Microsoft BASIC:
  638.  
  639.                  WHILE {condition}                 _____
  640.                       statements to repeat while {condition} is true
  641.                  ENDWHILE                 ________
  642.  
  643.             When using the WHILE block, remember that the {condition} is
  644.         tested before the statements in the body of the loop are ever
  645.         executed, so it's possible to not do them at all.  Also, be sure
  646.         you use ENDWHILE instead of WEND in Structured BASIC, or
  647.         SB.EXE will give you an error message.  When the BASIC program is
  648.         generated, a WHILE block will not have any Microsoft WHILE
  649.         statements in it.  Instead, IFs and GOTOs are used to make the
  650.         loop, so the program can be converted to computers that don't
  651.         have as advanced a version of BASIC.
  652.  
  653.         You can also use BREAK to get out of a WHILE loop.
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.                                                                         Page 11        100784112         Preprocessor User's Manual
  662.  
  663.  
  664.  
  665.         INCLUDE FILES        INCLUDE FILES
  666.  
  667.             A useful technique in programming is designing a program as a
  668.         set of small, independent modules.  This makes programs easier to
  669.         change, since revisions (like a changing the layout of a file)
  670.         only affect a small component (the subroutines that read or write
  671.         the file).  Modular programming is hard to do with BASIC because
  672.         all the pieces of your program must be present in a single file,
  673.         with one set of line numbers.  To help you develop your programs
  674.         as small modules, Structured BASIC has an INCLUDE statement.
  675.         Before telling you what it does, here's what it looks like:
  676.  
  677.                  INCLUDE {filename.ext}                 _____
  678.  
  679.             INCLUDE is used to bring statements into a program from a
  680.         completely separate file during preprocessing, to be part of the
  681.         program when it's translated into BASIC.  The statements in the
  682.         "included" file are also Structured BASIC statements.  They can
  683.         define and reference labels, procedures, and blocks exactly as if
  684.         they were in the original source file.  In fact, the INCLUDEd
  685.         file can itself have INCLUDE statements in it.
  686.  
  687.             INCLUDE is an extremely useful feature of Structured BASIC,
  688.         because now you can write frequently-used pieces of programs,
  689.         such as input routines and screen formatters, once as sets of
  690.         Structured BASIC procedures and just INCLUDE them into each new
  691.         program that you write.  When you edit these new programs you
  692.         don't have to manually APPEND the pieces, since SB.EXE will
  693.         automatically take care of the line numbering for you.  (But not
  694.         the variables.)
  695.  
  696.  
  697.  
  698.         MULTIPLE STATEMENTS        MULTIPLE STATEMENTS
  699.  
  700.             In BASIC programs, you can write several statements on a
  701.         single line by separating them with the {:} character.  Since
  702.         SB.EXE creates a BASIC program from the statements you give it,
  703.         the {:} character will work just as it does in BASIC, but with an
  704.         important exception: the special Structured BASIC statements
  705.         mentioned here cannot be used in multiple lines.  Instead, they                       ______
  706.         must have their own line whenever you use them.  This restriction
  707.         may change in another version of SB.EXE.
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.                                                                         Page 12        100784112         Preprocessor User's Manual
  722.  
  723.  
  724.  
  725.         ERROR MESSAGES        ERROR MESSAGES
  726.  
  727.             When SB.EXE processes your program, it makes two sweeps or
  728.         "passes" across it.  The first pass checks for errors.  There
  729.         aren't very many that you can make, since most of your program
  730.         will be passed through, untouched except for the addition of line
  731.         numbers, to BASIC.  There are, however, a few ways to produce an
  732.         error message.  The possible messages that you can get are listed
  733.         below, along with an explanation of how to fix the statement that
  734.         caused them.  All of these messages will begin with the name of
  735.         the file being processed (since the error might be in an INCLUDEd
  736.         file) and the offending line number.
  737.  
  738.  
  739.         label {name} defined previously at {file} line {n}
  740.  
  741.             If this error message is displayed it means you have defined
  742.             the label {name} twice (or more...) in your program.  A good
  743.             candidate for the source of this problem is an INCLUDEd file
  744.             with a duplicate of a label you are using in your program.
  745.  
  746.  
  747.         label {name} referenced at {file} line {n} undefined
  748.  
  749.             This error message is saying that you have forgotten to
  750.             define the label {name} in your program.  Possible causes of
  751.             this are forgetting an INCLUDE file (especially likely if you
  752.             see a lot of these messages) or misspelling the label.
  753.  
  754.  
  755.         label {name} type mismatch with {file} line {n}
  756.  
  757.             This error message is displayed when you try to GOTO a
  758.             procedure name or DO a LABEL|.
  759.  
  760.  
  761.         {type} block not active
  762.  
  763.             You used an ENDIF, ENDWHILE, or UNTIL statement in your
  764.             program without first using IF, WHILE, or REPEAT.
  765.  
  766.  
  767.         {type} block already begun at {file} line {n}
  768.  
  769.             You tried to put two ELSE statements in one IF block.  You
  770.             have probably forgotten an IF statement somewhere.
  771.  
  772.  
  773.         procedure {name} already begun at {file} line {n}
  774.  
  775.             You cannot have two procedures started at the same time.  You
  776.             must end the first procedure, {name}, with an ENDPROC
  777.             statement before you can begin your new procedure.
  778.  
  779.  
  780.  
  781.                                                                         Page 13        100784112         Preprocessor User's Manual
  782.  
  783.  
  784.  
  785.         procedure not begun first
  786.  
  787.             This error message means that an ENDPROC statement was found
  788.             in your program when no PROCEDURE statement was active.
  789.  
  790.  
  791.         no WHILE or REPEAT for BREAK
  792.  
  793.             This error message is displayed when you use a BREAK
  794.             statement outside a WHILE or REPEAT blocks.  Remember that a
  795.             BREAK transfers control to the statement immediately after
  796.             the nearest ENDWHILE or UNTIL.
  797.  
  798.  
  799.  
  800.         SB.EXE ABORTS        SB.EXE ABORTS
  801.  
  802.             If you specify a source or object filename that can't be read
  803.         or written to for some reason (such as the name being misspelled,
  804.         the diskette having its write-protect notch covered, etc.) the
  805.         preprocessor program will print the message:
  806.  
  807.                  Can't open file: {filename.ext}
  808.  
  809.         If this happens, you should check to make sure that the source
  810.         file can be read, that any INCLUDEd files it uses can be read,
  811.         and that the object file can be written to.
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.                                                                         Page 14        100784112         Preprocessor User's Manual
  842.  
  843.  
  844.  
  845.         PREPROCESSOR SPEED        PREPROCESSOR SPEED
  846.  
  847.             This version of SB.EXE can process your programs at the
  848.         rate of 120-300 lines per minute.  As you can see, this rate is
  849.         highly variable and is based on a number of factors, such as the
  850.         speed of your disk drives, the version of MS DOS you are using,
  851.         even the location of the files on the diskette.  If you have
  852.         frequently-used INCLUDE files you might want to consider putting
  853.         them on a RAM disk if you aren't going to change them often. This
  854.         should improve processing time a lot.
  855.  
  856.  
  857.         KNOWN BUGS        KNOWN BUGS
  858.  
  859.             There are a two known bugs in this release of SB.EXE.  The
  860.         first involves writing the output BASIC program to a nearly-full
  861.         diskette.  When this happens, no warning error occurs, and only
  862.         part of the program is written.  Check to make sure this doesn't
  863.         happen when your working diskettes are nearly full.
  864.  
  865.             The second bug concerns error recovery when many REPEAT,
  866.         WHILE, and IF blocks are nested.  When an error occurs, the error
  867.         message might not tell you the block in error.  Check all the
  868.         logic blocks in the vicinty of the statements mentioned for an
  869.         error.
  870.  
  871.             These bugs will be fixed in the next version of the
  872.         Structured BASIC preprocessor.
  873.  
  874.  
  875.         SB VS. BASIC        SB VS. BASIC
  876.  
  877.             Once you've mastered the Structured BASIC statements, there
  878.         aren't many reasons to continue entering and debugging BASIC
  879.         programs the old way.  You'll probably find that with a little
  880.         practice Structured BASIC programs really are easier to write and
  881.         maintain.  The only reasons to modify the translated BASIC
  882.         programs directly are:
  883.  
  884.             1.  Quick "patches" or minor changes to the BASIC program
  885.                 when the Structured BASIC source code isn't available or
  886.                 there isn't time to edit it again. (Such as when you're
  887.                 at the customer's office and the payroll program isn't
  888.                 working.)
  889.  
  890.             2.  "Fine tuning" for better performance, to straighten out
  891.                 Structured BASIC's "inside out" IF statements and extra
  892.                 GOTOs in programs where speed and memory size are
  893.                 crucial.
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.                                                                         Page 15        100784112         Preprocessor User's Manual
  902.  
  903.  
  904.  
  905.         STATEMENT REFERENCE        STATEMENT REFERENCE
  906.  
  907.             Here's a list of all the special statements available to you
  908.         in this version of SB.EXE.  For a complete description of how to
  909.         use them, see the individual sections in this manual.
  910.  
  911.                  BREAK
  912.  
  913.                  DO {procname}
  914.  
  915.                  ELSE
  916.  
  917.                  ELSIF
  918.  
  919.                  ENDIF
  920.  
  921.                  ENDPROC
  922.  
  923.                  ENDWHILE
  924.  
  925.                  IF {condition}
  926.                  IF {condition} BREAK
  927.                  IF {condition} DO {procname}
  928.                  IF {condition} GOSUB {procname}
  929.                  IF {condition} GOTO {procname}
  930.                  IF {condition} THEN {any BASIC statement}
  931.  
  932.                  GOSUB {procname}
  933.  
  934.                  GOTO {label}
  935.  
  936.                  INCLUDE {d:filename.ext}
  937.  
  938.                  ON n DO {procname1},{procname2},...
  939.                  ON COM(n) DO {procname}
  940.                  ON KEY(n) DO {procname}
  941.                  ON PEN DO {name}
  942.                  ON PLAY(n) DO {procname}
  943.                  ON STRIG(n) DO {procname}
  944.                  ON TIMER(n) DO {procname}
  945.  
  946.                  ON n GOTO {label1},{label2},...
  947.                  ON ERROR GOTO {label}
  948.  
  949.                  REPEAT
  950.  
  951.                  RESTORE {label}
  952.  
  953.                  RESUME {label}
  954.  
  955.                  RETURN {label}
  956.  
  957.                  UNTIL {condition}
  958.  
  959.                  WHILE {condition}
  960.  
  961.                                                                         Page 16        100784112         Preprocessor User's Manual
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.                                                                         Page 17        100784112